///Digital connectedness and political knowledge
use "/Users/mattluttig/Desktop/Police Shootings Knowledge Papers/YPP_Wave_3_ml.dta"


///Tetrachoric correlations
corr ericgarner michaelbrown marissaalexander cecemcdonald johncrawford3 renishamcbride partymajority veto conservativeparty judicialreview joebiden
corr politicalknowledge knowledgepoliceencounters

tetrachoric ericgarner michaelbrown marissaalexander cecemcdonald johncrawford3 renishamcbride partymajority veto conservativeparty judicialreview joebiden


///Factor analysis

factor ericgarner michaelbrown marissaalexander cecemcdonald johncrawford3 renishamcbride partymajority veto conservativeparty judicialreview joebiden, pcf
rotate

///CFA Analyses
sem (CARCKNOW -> ericgarner michaelbrown marissaalexander cecemcdonald johncrawford3 renishamcbride) (TRADKNOW -> partymajority veto conservativeparty judicialreview joebiden), stand
estat gof, stats(all)

sem (KNOW -> ericgarner michaelbrown marissaalexander cecemcdonald johncrawford3 renishamcbride partymajority veto conservativeparty judicialreview joebiden), stand
estat gof, stats(all)


///CFA using tetrachoric correlations (method artifact?)
clear
ssd init pm vp cp jr jb eg mb ma cm jc rm
ssd set obs 2772

ssd set cor  1.000 \ ///
			 0.39 1.000 \ ///							
			 0.51 0.48 1.000 \ ///						
		     0.44 0.46 0.55 1.000 \ ///					
			 0.52 0.53 0.61 0.60 1.000 \ ///			
			 0.29 0.23 0.26 0.29 0.46 1.000 \ /// 				
			 0.34 0.24 0.31 0.29 0.49 0.74 1.000 \ ///
			 0.10 0.07 0.09 0.12 0.13 0.24 0.24 1.000 \ ///		
			 0.11 0.12 0.11 0.16 0.30 0.34 0.40 0.53 1.000 \ ///
			 0.26 0.23 0.27 0.27 0.39 0.84 0.59 0.33 0.44 1.000 \ ///
			 0.17 0.12 0.10 0.14 0.26 0.35 0.34 0.73 0.61 0.43 1.000 

sem (CARCKNOW -> eg mb ma cm jc rm) (TRADKNOW -> pm vp cp jr jb), stand
estat gof, stats(all)

sem (KNOW -> eg mb ma cm jc rm pm vp cp jr jb), stand
estat gof, stats(all)

sem (CARCKNOW -> eg mb ma cm jc rm) (TRADKNOW -> pm vp cp jr jb), stand
estat gof, stats(all)

sem (KNOW -> eg mb ma cm jc rm pm vp cp jr jb), stand
estat gof, stats(all)

///IRT models and ICC curves
irt 2pl partymajority veto conservativeparty judicialreview joebiden if white==1
irt 2pl partymajority veto conservativeparty judicialreview joebiden if black==1
irt 2pl partymajority veto conservativeparty judicialreview joebiden if hispanic==1
irtgraph icc

irt 2pl partymajority veto conservativeparty judicialreview joebiden
predict irttrad, latent

irt 2pl ericgarner michaelbrown marissaalexander cecemcdonald johncrawford3 renishamcbride if white==1
irt 2pl ericgarner michaelbrown marissaalexander cecemcdonald johncrawford3 renishamcbride if black==1
irt 2pl ericgarner michaelbrown marissaalexander cecemcdonald johncrawford3 renishamcbride if hispanic==1
irtgraph icc

irt 2pl ericgarner michaelbrown marissaalexander cecemcdonald johncrawford3 renishamcbride if white==1
predict irtcarc, latent


///Figure 1
svy: reg politicalknowledge i.race 
svy: reg knowledgepoliceencounters i.race 

svy: reg politicalknowledge i.race educ4 ppage female spanish married employed south ABS
svy: reg knowledgepoliceencounters i.race educ4 ppage female spanish married employed south ABS


///Figure 2
svy: reg partymajority i.race
margins, over(race)
marginsplot, recast(bar) horizontal

svy: reg joebiden i.race
margins, over(race)
marginsplot, recast(bar) horizontal

svy: reg johncrawford3 i.race
margins, over(race)
marginsplot, recast(bar) horizontal

svy: reg cecemcdonald i.race
margins, over(race)
marginsplot, recast(bar) horizontal

///Percentage of Respondents Answering Each Knowledge Question Correctly, by Race/Ethnicity (Table 1)
tab partymajority if black==1 
tab partymajority if hispanic==1 
tab partymajority if white==1 

tab veto if black==1 
tab veto if hispanic==1 
tab veto if white==1 

tab conservativeparty if black==1 
tab conservativeparty if hispanic==1 
tab conservativeparty if white==1 

tab judicialreview if black==1 
tab judicialreview if hispanic==1 
tab judicialreview if white==1 

tab joebiden if black==1 
tab joebiden if hispanic==1 
tab joebiden if white==1 

tab ericgarner if black==1 
tab ericgarner if hispanic==1 
tab ericgarner if white==1 

tab michaelbrown if black==1 
tab michaelbrown if hispanic==1 
tab michaelbrown if white==1 

tab johncrawford3 if black==1 
tab johncrawford3 if hispanic==1 
tab johncrawford3 if white==1 

tab marissaalexander if black==1 
tab marissaalexander if hispanic==1 
tab marissaalexander if white==1 

tab cecemcdonald if black==1 
tab cecemcdonald if hispanic==1 
tab cecemcdonald if white==1 

tab renishamcbride if black==1 
tab renishamcbride if hispanic==1 
tab renishamcbride if white==1 

///Knowledge as Outcome Models (Table 2)

svy, subpop(black): reg knowledgepoliceencounters01 educ4 frequencyinternetaccess socialconnectedness onlinehomophily websitesofcolor discusspoliticsfacetoface discusspoliticsonline polinterest TVnews Printnews twitternews politicalblog ppage female spanish married employed south ABS 
svy, subpop(black): reg politicalknowledge01 educ4 frequencyinternetaccess socialconnectedness onlinehomophily websitesofcolor discusspoliticsfacetoface discusspoliticsonline polinterest TVnews Printnews twitternews politicalblog ppage female spanish married employed south ABS 

svy, subpop(white): reg knowledgepoliceencounters01 educ4 frequencyinternetaccess socialconnectedness onlinehomophily websitesofcolor discusspoliticsfacetoface discusspoliticsonline polinterest TVnews Printnews twitternews politicalblog ppage female spanish married employed south ABS 
svy, subpop(white): reg politicalknowledge01 educ4 frequencyinternetaccess socialconnectedness onlinehomophily websitesofcolor discusspoliticsfacetoface discusspoliticsonline polinterest TVnews Printnews twitternews politicalblog ppage female spanish married employed south ABS 

svy, subpop(hispanic): reg knowledgepoliceencounters01 educ4 frequencyinternetaccess socialconnectedness onlinehomophily websitesofcolor discusspoliticsfacetoface discusspoliticsonline polinterest TVnews Printnews twitternews politicalblog ppage female spanish married employed south ABS 
svy, subpop(hispanic): reg politicalknowledge01 educ4 frequencyinternetaccess socialconnectedness onlinehomophily websitesofcolor discusspoliticsfacetoface discusspoliticsonline polinterest TVnews Printnews twitternews politicalblog ppage female spanish married employed south ABS 


///Knowledge as Predictors (Table 3)

svy, subpop(black): reg linkedfate knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(black): reg internalefficacy knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(black): reg externalefficacy knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(black): reg vote knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(black): reg protest knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS

svy, subpop(white): reg linkedfate knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(white): reg internalefficacy knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(white): reg externalefficacy knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(white): reg vote knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(white): reg protest knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS

svy, subpop(hispanic): reg linkedfate knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(hispanic): reg internalefficacy knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(hispanic): reg externalefficacy knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(hispanic): reg vote knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS 
svy, subpop(hispanic): reg protest knowledgepoliceencounters01 politicalknowledge01 educ4 ppage female spanish married employed south ABS




